import java.util.logging.Logger;

public class Blink extends Plugin {
    private final String name = "Blink";
    private final float version = 0.1f;
    private final Listener listener = new Listener();
    private static final Logger log = Logger.getLogger("Minecraft");
    private final static int ITEM = 280; //Item that must be held to blink
    
	public Blink() {}

	@Override
	public void disable() {
        log.info(String.format("%s %.2f was disabled", name, version));		
	}

	@Override
	public void enable() {
        log.info(String.format("%s %.2f was enabled", name, version));		
	}
    @Override
    public void initialize() {
        etc.getLoader().addListener(PluginLoader.Hook.ARM_SWING, listener , this, PluginListener.Priority.MEDIUM);
    }
    
    private class Listener extends PluginListener {
        @Override
        public void onArmSwing(Player player) {
        	if (player.canUseCommand("/blink") && player.getItemInHand() == Blink.ITEM) {
        		Block clicked = new HitBlox(player).getFaceBlock();
        		player.teleportTo(clicked.getX(),clicked.getY()+1.7,clicked.getZ(), player.getRotation(), player.getPitch());
        	}
        }
    }

}
